import Vue from 'vue'
import Vuex from 'vuex'
import { getUserInfo  } from '@/api'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user:{
      // id:"80f4dd97-2ee8-449e-822c-bb62eb2a9755",
      id:"",
      name:"",
      mobile:"",
      idNo:"",
      userType:''
    }

  },
  mutations: {
    setUserinfo(state,playload){
      state.user.id = playload.id;
      state.user.name = playload.name;
      state.user.mobile = playload.mobile;
      state.user.idNo = playload.idNo;
      state.user.userType=playload.userType;
      // console.log(state.user,'state.user')
    }
  },
  actions: {
    getUser(context,playload){
      let url = '/sys/sysMember/getMember';
      getUserInfo(url).then(res=>{
        
        if(res.data.code == 200){
          context.commit('setUserinfo',{
            id:res.data.data.id,
            name:res.data.data.realName,
            mobile:res.data.data.mobile,
            idNo:res.data.data.idNo,
            userType:res.data.data.userType,
          })
        }
      })
    },
  },
  modules: {
  }
})
